package com.wk.code.wkserver.controller.admin;

import com.wk.code.wkserver.entity.SysConfig;
import com.wk.code.wkserver.entity.TechType;
import com.wk.code.wkserver.request.admin.SysConfigRequest;
import com.wk.code.wkserver.request.admin.TechTypeRequest;
import com.wk.code.wkserver.response.admin.TechTypeResponse;
import com.wk.code.wkserver.response.base.PageInfo;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.ISysConfigService;
import com.wk.code.wkserver.service.ITechTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 后台系统配置 前端控制器
 * </p>
 *
 * @author wq
 * @since 2021-08-15
 */
@RestController
@RequestMapping("admin/sysConfig")
@AllArgsConstructor
@Api(tags = "admin-后台系统配置管理")
public class AdminSysConfigController {

    final ISysConfigService sysConfigService;


    /**
     * 分页列表
     *
     * @param req 请求参数
     * @return R
     */
    @ApiOperation(value = "分页列表")
    @PostMapping("/page")
    public R<PageInfo<SysConfig>> page(@RequestBody SysConfigRequest req) {
        return R.success(sysConfigService.page(req));
    }

    /**
     * 添加
     *
     * @param req 请求参数
     * @return R
     */
    @ApiOperation(value = "添加")
    @PostMapping("/add")
    public R<Void> add(@RequestBody SysConfigRequest req) {
        sysConfigService.add(req);
        return R.success();
    }

    /**
     * 更新
     *
     * @param req req
     * @return R
     */
    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public R<Void> update(@RequestBody SysConfigRequest req) {
        sysConfigService.update(req);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "详情")
    @GetMapping("/detail")
    private R<SysConfig> detail(Integer id) {
        return R.success(sysConfigService.detail(id));
    }

    /**
     * 删除
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "删除")
    @GetMapping("/delete")
    private R<Void> delete(Integer id) {
        sysConfigService.delete(id);
        return R.success();
    }


}
